import Cookie from 'js-cookie'
export default {
  
  state: {
    currentMenu: null,
    collaMenu:false,
    tabList:[{
    path: '/',
    name: '首页',
    label: 'home',
    }]
  },
  mutations: {
    selectMenu(state, val) {
      val.label === 'home' ? (state.currentMenu = null) : (state.currentMenu = val)
      //看tabList中是否有val name属性相同的元素，有返回1，没有返回-1
      let index=state.tabList.findIndex(e=>e.name===val.name)
      if(index===-1){
          state.tabList.push(val);   
      }

    },
    closeTag(state,val){

      //找到被点击的隐藏的元素，进行删除
      let index=state.tabList.findIndex(item=>item.name===val.name);
      //找到元素的索引并进行删除
      index!==-1?state.tabList.splice(index,1):''
    },
    collaMenu(state){
      state.collaMenu=!state.collaMenu;
    }
    
  },
  actions: {}
}
